// @ts-expect-error defineFakeRoute
import { defineFakeRoute } from "vite-plugin-fake-server/client";
// @ts-expect-error ProcessedRequest
import type { ProcessedRequest } from "vite-plugin-fake-server";

export default defineFakeRoute([
  {
    url: "/login",
    method: "get",
    response: (processedRequest: ProcessedRequest) => {
      const { username, password } = processedRequest.body;
      if (username === "admin" && password === "admin") {
        return {
          code: 200,
          message: "success",
          data: {
            userInfo: {
              name: "花东红",
              age: 24
            },
            token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODI5NDU5NTIsIm5hbWUiOiIxNTMwMTcxNjE3MiIsInVzZXJfaWQiOiIwMUdXMUQ2RERKN0RHWU5BRUhBWEhHRlpQWiJ9.3X3pqrZAQzUM-BZOz_EHwwHIiRFZaz3UewsfxICYr0c"
          }
        };
      } else {
        return {
          code: 403,
          message: "用户名不存在",
          data: {}
        };
      }
    }
  }
]);
